<?php
use Inationsoft\NS\Core\Model;

class UserRoleModel extends Model {
	function __construct() {
		parent::__construct('koma_users_roles');

		$this->hasOne(Model::getInstance('RoleManagementModel'), 'rid');
	}

	function getAll($columns = null, $condition = null, $order = null, $offset = null, $limit = null) {
		$this->findAll($columns, $condition, $order, $offset, $limit);

		return $this->toArray();
	}

	function saveData($data) {
		if($this->find(null, array('uid' => $data['uid'], 'rid' => $data['rid']))) {
		} else $this->populate($data, false);

		return $this->save();
	}
}
?>